//index.js
//获取应用实例
var app = getApp()
Page({
    data: {
        motto: 'Hello World',
        URL: app.globalData.url,
        userInfo: {},
        banner:[],
        nav_btn: [ //导航按钮
            {
                icon: '/images/icon/sell.png',
                name: '热销排行',
                page: 'index',
                data: 'id=8&name=杨恒'
            }, {
                icon: '/images/icon/preferential.png',
                name: '本周特惠',
                page: 'index',
                data: 'id=8&name=杨恒'
            }, {
                icon: '/images/icon/collect.png',
                name: '我的收藏',
                page: 'index',
                data: 'id=8&name=杨恒'
            }, {
                icon: '/images/icon/order.png',
                name: '我的订单',
                page: 'index',
                data: 'id=8&name=杨恒'
            }
        ],
        container_1: { //板块一  模拟数据
            title: '整点秒杀',
            desc: '18点场',
            list: [{
                imgUrl: 'http://img95.699pic.com/photo/00013/9236.jpg_wh300.jpg',
                name: '测试阿萨德撒多撒大所大所大所多撒大所大所多商品1',
                price: '998.00',
                id: '1'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00033/2782.jpg_wh300.jpg',
                name: '测试商品2',
                price: '998.00',
                id: '2'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00014/2719.jpg_wh300.jpg',
                name: '测试商品3',
                price: '998.00',
                id: '3'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00001/3465.jpg_wh300.jpg',
                name: '测试商品4',
                price: '998.00',
                id: '4'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50039/9046.jpg_wh300.jpg',
                name: '测试商品5',
                price: '998.00',
                id: '5'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50046/3694.jpg_wh300.jpg',
                name: '测试商品6',
                price: '',
                id: '6'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00013/9236.jpg_wh300.jpg!',
                name: '测试商品1',
                price: '998.00',
                id: '1'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00033/2782.jpg_wh300.jpg',
                name: '测试商品2',
                price: '998.00',
                id: '2'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00014/2719.jpg_wh300.jpg',
                name: '测试商品3',
                price: '998.00',
                id: '3'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00001/3465.jpg_wh300.jpg',
                name: '测试商品4',
                price: '998.00',
                id: '4'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50039/9046.jpg_wh300.jpg',
                name: '测试商品5',
                price: '998.00',
                id: '5'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50046/3694.jpg_wh300.jpg',
                name: '测试商品6',
                price: '',
                id: '6'
            }]
        },
        container_2: { //板块二  模拟数据
            title: '每日新品',
            list: [{
                imgUrl: 'http://img95.699pic.com/photo/00001/3465.jpg_wh300.jpg',
                name: '测试阿萨德撒多撒大所大所大所多撒大所大所多商品1',
                price: '998.00',
                id: '1'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00033/2782.jpg_wh300.jpg',
                name: '测试商品2',
                price: '998.00',
                id: '2'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00014/2719.jpg_wh300.jpg',
                name: '测试商品3',
                price: '998.00',
                id: '3'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00013/9236.jpg_wh300.jpg',
                name: '测试商品4',
                price: '998.00',
                id: '4'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50039/9046.jpg_wh300.jpg',
                name: '测试商品5',
                price: '998.00',
                id: '5'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50046/3694.jpg_wh300.jpg',
                name: '测试商品6',
                price: '',
                id: '6'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00013/9236.jpg_wh300.jpg!',
                name: '测试商品1',
                price: '998.00',
                id: '1'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00033/2782.jpg_wh300.jpg',
                name: '测试商品2',
                price: '998.00',
                id: '2'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00014/2719.jpg_wh300.jpg',
                name: '测试商品3',
                price: '998.00',
                id: '3'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00001/3465.jpg_wh300.jpg',
                name: '测试商品4',
                price: '998.00',
                id: '4'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50039/9046.jpg_wh300.jpg',
                name: '测试商品5',
                price: '998.00',
                id: '5'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50046/3694.jpg_wh300.jpg',
                name: '测试商品6',
                price: '',
                id: '6'
            }]
        },
        container_3: { //板块三  模拟数据
            title: '推荐商品',
            list: [{
                imgUrl: 'http://img95.699pic.com/photo/00001/3465.jpg_wh300.jpg',
                name: '测试阿萨德撒多撒大所大所大所多撒大所大所多商品1',
                price: '998.00',
                id: '1'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00033/2782.jpg_wh300.jpg',
                name: '测试商品2',
                price: '998.00',
                id: '2'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00014/2719.jpg_wh300.jpg',
                name: '测试商品3',
                price: '998.00',
                id: '3'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00013/9236.jpg_wh300.jpg',
                name: '测试商品4',
                price: '998.00',
                id: '4'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50039/9046.jpg_wh300.jpg',
                name: '测试商品5',
                price: '998.00',
                id: '5'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50046/3694.jpg_wh300.jpg',
                name: '测试商品6',
                price: '',
                id: '6'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00013/9236.jpg_wh300.jpg!',
                name: '测试商品1',
                price: '998.00',
                id: '1'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00033/2782.jpg_wh300.jpg',
                name: '测试商品2',
                price: '998.00',
                id: '2'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00014/2719.jpg_wh300.jpg',
                name: '测试商品3',
                price: '998.00',
                id: '3'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/00001/3465.jpg_wh300.jpg',
                name: '测试商品4',
                price: '998.00',
                id: '4'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50039/9046.jpg_wh300.jpg',
                name: '测试商品5',
                price: '998.00',
                id: '5'
            }, {
                imgUrl: 'http://img95.699pic.com/photo/50046/3694.jpg_wh300.jpg',
                name: '测试商品6',
                price: '',
                id: '6'
            }]
        }
    },
    //事件处理函数
    bindViewTap: function() {
        wx.navigateTo({
            url: '../logs/logs'
        })
    },
    onLoad: function(options) {
      var that = this;
        wx.setStorageSync('pages', ['/pages/index/index']);
        // console.log(app.globalData.url);
        wx.request({
          url: app.globalData.url +'/api/index/index',
          success:function(res){
            // console.log(res.data.inslide);
            that.setData({
              banner: res.data.inslide,
              container_1: res.data.hot_goods
            })
          }
        })

    },
    /**
     * 扫描二维码
     */
    sweep: function() {
        wx.scanCode({
            success: (res) => {
                console.log(res.result);
                wx.reLaunch({
                    url: res.result,
                    fail: function(e) {
                        wx.showModal({
                            title: '错误！',
                            content: '二维码错误请重新扫描。',
                        })
                    }
                })
            }
        })
    },
    /**
     * 搜索
     */
    search: function(e) {
        console.log(e);
    },
    /**
     * 调用全局页面跳转函数
     */
    goToPage: function(e) {
        app.goToPage(e);
    },
    /**
     * 扫描二维码
     */
    sweep: function() {
        wx.scanCode({
            success: (res) => {
                console.log(res.result);
                wx.reLaunch({
                    url: res.result,
                    fail: function(e) {
                        wx.showModal({
                            title: '错误！',
                            content: '二维码错误请重新扫描。',
                        })
                    }
                })
            }
        })
    }
})